<template>
  <view class="da-dropdown-filter">
	<view class="da-dropdown-filter-box">
		<view class="da-dropdown-filter-content">  
			<uni-combox :candidates="candidates" placeholder="请选择所在城市" v-model="city"></uni-combox>
		</view>
    </view>
	<PartDropdownFooter
	  :resetText="dropdownItem.resetText"
	  :confirmText="dropdownItem.confirmText"
	  @reset="handleReset()"
	  @confirm="handleConfirm()"></PartDropdownFooter>
  </view>
</template>

<script>
import { deepClone } from '../utils'
import PartDropdownFooter from './part-dropdown-footer.vue'
export default {
  components: { PartDropdownFooter },
  props: {
	  dropdownItem: {
	    type: Object,
	    default: null,
	  },
	  dropdownIndex: {
	    type: Number,
	  },
    
  },
  data() {
    return {
      filterList: null,
	  candidates: ['北京', '南京', '东京', '武汉', '天津', '上海', '海口1','海口2','海口3','海口4','海口5'],
	  city:""
    }
  },
  watch: {
    
  },
  methods: {
	  handleReset() {
	    this.initData(this.dropdownItem || [], true)
	  },
	  handleConfirm() {
	    const list = deepClone(this.filterList)
	  
	    if (this.dropdownItem?.prop) {
	      const obj = {}
	      for (let i = 0; i < list.length; i++) {
	        const k = list[i]
	        if (k.value || k.value === 0) {
	          obj[k.prop] = k.value
	        }
	      }
	      const res = { [this.dropdownItem.prop]: obj }
	      this.$emit('success', res, obj, this.dropdownIndex)
	    } else {
	      console.error(`菜单项${this.dropdownItem.title}未定义prop，返回内容失败`)
	    }
	  },
    
  },
}
</script>

